// 物料onchange事件
OB.Emes_ActionButton.MaterialOnChange = function(item, view, form, grid) {
	var changeData = item.getValue();
	if (changeData != null && changeData != 'null') {
		var id = item._value;
		OB.RemoteCallManager.call("com.mes.handler.plan.GetMaterialInFoHandler", {
					productId : id
				}, {}, function(rpcResponse, data, rpcRequest) {
					try {
					form.setItemValue('product$name', data.Name);
					form.setItemValue('product$name2',data.Name2)
					} catch (e) {
						// TODO: handle exception
					}
				});
	}
	return true;
};

//物料onchange事件2
OB.Emes_ActionButton.MaterialOnChange2 = function(item, view, form, grid) {
	var changeData = item.getValue();
	if (changeData != null && changeData != 'null') {
		var id = item._value;
		OB.RemoteCallManager.call("com.mes.handler.plan.GetMaterialInFoHandler", {
					productId : id
				}, {}, function(rpcResponse, data, rpcRequest) {
					try {
					form.setItemValue('product$name', data.Name);
					form.setItemValue('product$name2',data.Name2);
					form.setItemValue('product$uOM$name',data.Uom);
					form.setItemValue('product$productCategory$searchKey',data.Category);
					
					} catch (e) {
						// TODO: handle exception
					}
				});
	}
	return true;
};

//工艺路线工序详情
OB.Emes_ActionButton.RouteOprInformation = function(item, view, form, grid) {
	var changeData = item.getValue();
	if (changeData != null && changeData != 'null') {
		var id = item._value;
		var type = item.name;
		OB.RemoteCallManager.call("com.mes.handler.FacilityMaintainInFoHandler", {
			MaintainID : id,type : type
				}, {}, function(rpcResponse, data, rpcRequest) {
					try {
						if(data.type == 'emesprocess'){
							form.setItemValue('emesProcessOpr$name',data.name);	
						}
					} catch (e) {
						// TODO: handle exception
					}
				});
	}
	return true;
};

//设备保养详情onchange事件
OB.Emes_ActionButton.MaintainDetailsOnChange = function(item, view, form, grid) {
	var changeData = item.getValue();
	if (changeData != null && changeData != 'null') {
		var id = item._value;
		var type = item.name;
		OB.RemoteCallManager.call("com.mes.handler.FacilityMaintainInFoHandler", {
			MaintainID : id,type : type
				}, {}, function(rpcResponse, data, rpcRequest) {
					try {
					if(data.type == 'maintain'){
						form.setItemValue('emesMaintain$maintainName',data.name);
						form.setItemValue('emesMaintain$maintainDetails',data.details);
						form.setItemValue('emesMaintain$maintainStandard',data.standard);	
					}else{
						form.setItemValue('emesRepair$name',data.name);
						form.setItemValue('emesRepair$details',data.details);
						form.setItemValue('emesRepair$standard',data.standard);
					}
					} catch (e) {
						// TODO: handle exception
					}
				});
	}
	return true;
};


//设备保养、维修详情onchange事件
OB.Emes_ActionButton.MRDetailsOnChange = function(item, view, form, grid) {
	var changeData = item.getValue();
	if (changeData != null && changeData != 'null') {
		var id = item._value;
		var type = item.name;
		OB.RemoteCallManager.call("com.mes.handler.FacilityMRInFoHandler", {
			P_ID : id,type : type
				}, {}, function(rpcResponse, data, rpcRequest) {
					try {
					if(data.type == 'maintain'){
						form.setItemValue('emesMaintain$maintainName',data.name);
						form.setItemValue('emesMaintain$maintainDetails',data.details);
						form.setItemValue('emesMaintain$maintainStandard',data.standard);	
					}else{
						form.setItemValue('emesRepair$name',data.name);
						form.setItemValue('emesRepair$details',data.details);
						form.setItemValue('emesRepair$standard',data.standard);
					}
					} catch (e) {
						// TODO: handle exception
					}
				});
	}
	return true;
};
